<template>
  <div>
    <ul>
      <li>news001 <input type="text" /></li>
      <li>news002 <input type="text" /></li>
      <li>news003 <input type="text" /></li>
      <li :style="{opacity}">欢迎学习Vue</li>
    </ul>
  </div>
</template>

<script>
export default {
  name: "News",
  data() {
    return {
      opacity: 1,
    };
  },
  activated() {
    //激活  组件独有
    this.timer = setInterval(() => {
      this.opacity -= 0.01;
      if (this.opacity <= 0) this.opacity = 1;
    }, 15);
  },
  deactivated() {
    //失活
    clearInterval(this.timer)
  },
};
</script>

<style>
</style>